<!-- 新增分区 -->
<template>
  <div style="padding: 15px 30px;">
    <!-- <el-dialog title="提审" :visible.sync="dialogShow" width="65%" :close-on-click-modal="false" :close-on-press-escape="false" :show-close="false"> -->
    <el-descriptions :column="2" v-for="(item, key) in list" :key="key" class="border-bottom-F2F2F2 margin-bottom-10 padding-left-right-10">
      <el-descriptions-item label="设施名称">{{ item.stationName }}</el-descriptions-item>
      <el-descriptions-item label="所在楼层">{{ item.floorName }}</el-descriptions-item>
      <el-descriptions-item label="设施状态">{{ item.statusName }}</el-descriptions-item>
    </el-descriptions>

    <div class="t-right padding-top-15">
      <!-- <el-button v-if="$route.query.IsUpcoming" type="primary" size="mini" @click="apisuccessAudit">审批通过</el-button> -->
      <!-- <el-button size="small" @click="hideDialog">取 消</el-button> -->
      <el-button v-if="!$route.query.processWorkId" size="small" type="primary" @click="approveFn">提 审</el-button>
    </div>
    <!-- </el-dialog> -->
    <ApproveInfo v-if="!!$route.query.processWorkId"></ApproveInfo>
  </div>
</template>
<script>
import { requestTips, askDialog } from '../../../../assets/util';
import projectInfoApi from '../../../../api/projectInfo';
import ApproveInfo from '../approveInfo.vue';
import { apisuccessAudit, apifailAudit } from '../../../../api/common';
export default {
   components: { ApproveInfo },
  props: {
    pageType: {
      type: String,
      default: '',
    },
  },
  data() {
    return {
      dialogShow: false,
      list: [],
      projectKey:this.$route.query.projectKey || localStorage.getItem("projectKey")
    };
  },

  mounted() {
    this.getInfo();
    console.log('SubmissionButton',this.$store.state.SubmissionButton)
  },

  methods: {
    apisuccessAudit() {
      apisuccessAudit({
        floorKey: this.$route.query.floorKey,
        projectKey: this.projectKey,
        systemType: this.$route.query.systemType,
        workId: this.$route.query.workId,
        workType: this.$route.query.workType,
      }).then(res => {
        if (res.success) {
          this.$message.success(res.message);
          window.location.replace(location.href + '&processWorkId=' + this.$route.query.workId);
        } else {
          this.$message.warning(res.message)
        };
      });
    },
    async getInfo() {
      let res = await projectInfoApi.apiFacilityApproInfo({
        workId: this.$route.query.workId,
        projectKey: this.projectKey,
      });
      res.rows.forEach(item => {
        item.statusName = item.status == 1 ? '正常' : '删除';
      });
      this.list = res.rows || [];
    },
    approveFn() {
      askDialog('确认提审？', async () => {
        let data = {
          workType: 4,
          projectKey: this.projectKey,
          workId: this.$route.query.workId,
        };
        let res = await projectInfoApi.summitAudit(data);
        requestTips(res, () => {
          this.$emit('btnStatus');
        });
      });
    },
    hideDialog() {
      this.dialogShow = false;
    },
  },
};
</script>
<style lang="scss" scoped></style>
